package com.gdou.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDto {
    private Long id;
    @NotNull
    @Pattern(regexp = "[\\u4e00-\\u9fa5]{2,10}",message = "姓名格式错误")
    private String username;

    // 时间格式化
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @NotNull
    private Date birthday;

    @NotNull(message = "性别格式错误")
    // @Pattern 被注解的元素必须符合给定的正则表达式
    @Pattern(regexp = "[10]",message = "性别格式错误")
    private String sex;

    @NotNull
    @Pattern(regexp = "[1][3456789][0-9]{9}",message = "手机格式错误")
    private String tel;
    @NotNull
    @Min(value = 0,message = "薪资格式错误")
    private Double sal;
    @NotNull
    private String profession;//职业

    @NotNull
    @Pattern(regexp = ".{6,20}",message = "地址格式错误")
    private String address;
    private String remark;//备注

    @NotNull(message = "部门格式错误")
    private Long deptId;
}
